/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) [2021] [Fudan Microelectronics]
  * THIS SOFTWARE is licensed under Mulan PSL v2.
  * can use this software according to the terms and conditions of the Mulan PSL v2.
  * You may obtain a copy of Mulan PSL v2 at:
  *          http://license.coscl.org.cn/MulanPSL2
  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  * See the Mulan PSL v2 for more details.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mf_config.h"


#if defined(USE_FULL_ASSERT)
#include "fm33_assert.h"
#endif /* USE_FULL_ASSERT */

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
extern uint16_t uiSysFlags;
/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
#define BIT0                                                           (0x0001)
#define BIT1                                                           (0x0002)
#define BIT2                                                           (0x0004)
#define BIT3                                                           (0x0008)
#define BIT4                                                           (0x0010)
#define BIT5                                                           (0x0020)
#define BIT6                                                           (0x0040)
#define BIT7                                                           (0x0080)
#define BIT8                                                           (0x0100)
#define BIT9                                                           (0x0200)
#define BIT10                                                          (0x0400)
#define BIT11                                                          (0x0800)
#define BIT12                                                          (0x1000)
#define BIT13                                                          (0x2000)
#define BIT14                                                          (0x4000)
#define BIT15                                                          (0x8000)

#define SET_POWER_KEY_TIMER()                                          (uiSysFlags |= BIT0)
#define GET_POWER_KEY_TIMER()                                          (uiSysFlags & BIT0)
#define CLR_POWER_KEY_TIMER()                                          (uiSysFlags &= ~BIT0)

#define SET_UART_RX_FINISH()                                           (uiSysFlags |= BIT1)
#define GET_UART_RX_FINISH()                                           (uiSysFlags & BIT1)
#define CLR_UART_RX_FINISH()                                           (uiSysFlags &= ~BIT1)

#define POWER_ON()                                                     FL_GPIO_SetOutputPin(GPIOA, FL_GPIO_PIN_4);
#define POWER_OFF()                                                    FL_GPIO_ResetOutputPin(GPIOA, FL_GPIO_PIN_4);

typedef struct{
	uint8_t ucHeader;
	uint8_t ucCmd;
	uint8_t ucType;
	uint8_t ucLen;
	uint8_t ucData0;
	uint8_t ucData1;
	uint8_t ucData2;
	uint8_t ucData3;
	uint8_t ucData4;
	uint8_t ucData5;
	uint8_t ucData6;
	uint8_t ucData7;
	uint8_t ucChecksum;
	uint8_t ucTail1;
	uint8_t ucTail2;
}STCmdFrame;

typedef struct{
	union{
		STCmdFrame stCmdFrame;
		uint8_t ucAryRxBuffer[16];
	}frame;
	
	uint8_t ucRxDataCnt;
}STRxDataFrame;
/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT FMSH *****END OF FILE****/
